import {createApp, provide} from 'vue'
import App from './App.vue'
import router from './router'
import { useRouter } from 'vue-router'
import * as echarts from 'echarts/core';
// 引入各种图表，图表后缀都为 Chart
import { BarChart } from 'echarts/charts';
// 引入提示框，标题，直角坐标系等组件，组件后缀都为 Component
import {
    TitleComponent,
    TooltipComponent,
    GridComponent,
    LegendComponent
} from 'echarts/components';
// 引入 Canvas 渲染器，注意引入 CanvasRenderer 或者 SVGRenderer 是必须的一步
import { CanvasRenderer } from 'echarts/renderers';
// 注册必须的组件
echarts.use(
    [TitleComponent, TooltipComponent, GridComponent, LegendComponent, BarChart, CanvasRenderer]
)
// import * as echarts from 'echarts'

// ElementPlus elementUi 不支持vue3.0
import { ElMessage,ElLoading} from 'element-plus'
import {
    ElButton,
    ElButtonGroup,
    ElCheckbox,
    ElCol,
    ElFooter,
    ElForm,
    ElFormItem,
    ElIcon,
    ElInput,
    ElTree,
    ElRow
} from 'element-plus';

import Axios from 'axios'



// step3：使每次请求都会带一个 /api 前缀
Axios.defaults.baseURL = '/api'

const components = [
    ElButton,
    ElButtonGroup,
    ElCheckbox,
    ElCol,
    ElFooter,
    ElForm,
    ElFormItem,
    ElIcon,
    ElInput,
    ElTree,
    ElRow
]

import 'element-plus/lib/theme-chalk/index.css';

const AppBase = createApp(App);
// AppBase.config.globalProperties.echarts = echarts;// vue3.0 不建议此用法
components.forEach(component => {
    AppBase.component(component.name, component)
})
AppBase.provide('$message', ElMessage)
AppBase.provide('echarts', echarts)
AppBase.provide('router', router)
AppBase.provide('elLoading', ElLoading)
AppBase.provide('$axios', Axios)
AppBase.use(router).mount('#app');
